﻿// <copyright file="ColorDialog.xaml.cs" company="Oleg V. Polikarpotchkin">
// Copyright © 2009 Oleg V. Polikarpotchkin. All Right Reserved
// </copyright>
// <author>Oleg V. Polikarpotchkin</author>
// <email>ov-p@yandex.ru</email>
// <date>2009-06-12</date>
// <summary>OpenWPFChart library.
// ColorDialog.
// </summary>
// <revision>$Id$</revision>

using System.Windows;
using System.Windows.Media;

namespace OpenWPFChart.Helpers.ChooseColorDialog
{
	/// <summary>
	/// Interaction logic for ColorDialog.xaml.
	/// </summary>
	/// <remarks>
	/// </remarks>
	public partial class ColorDialog : Window
	{
		/// <summary>
		/// Initializes a new instance of the <see cref="ColorDialog"/> class.
		/// </summary>
		public ColorDialog()
		{
			InitializeComponent();

			AddHandler(ColorChooser.SelectedColorChangedEvent
				, new SelectedColorChangedEventHandler(SelectedColorPropertyChanged));
		}
		/// <summary>
		/// Initializes a new instance of the <see cref="ColorDialog"/> class.
		/// </summary>
		/// <param name="color">The initial color value.</param>
		public ColorDialog(Color color) : this()
		{
			colorChooser.SelectedColor = color;
			btnOK.IsEnabled = false;
		}
		/// <summary>
		/// Initializes a new instance of the <see cref="ColorDialog"/> class.
		/// </summary>
		/// <param name="color">The initial color value.</param>
		/// <param name="IsColorPickerVisible">if set to <c>true</c> the color picker is visible.</param>
		public ColorDialog(Color color, bool IsColorPickerVisible) : this(color)
		{
			colorChooser.IsColorPickerVisible = IsColorPickerVisible;
		}

		/// <summary>
		/// SelectedColor property changed event handler.
		/// </summary>
		/// <param name="sender">The sender.</param>
		/// <param name="e">The <see cref="ovp.WPFGears.SelectedColorChangedEventArgs"/> 
		/// instance containing the event data.</param>
		void SelectedColorPropertyChanged(object sender, SelectedColorChangedEventArgs e)
		{
			btnOK.IsEnabled = true;
		}

		/// <summary>
		/// Gets the color selected.
		/// </summary>
		/// <value>The color value.</value>
		public Color SelectedColor
		{
			get { return colorChooser.SelectedColor; }
		}

		/// <summary>
		/// Gets a value indicating whether the color picker is visible.
		/// </summary>
		/// <value>
		/// 	<c>true</c> if the color picker is visible; otherwise, <c>false</c>.
		/// </value>
		public bool IsColorPickerVisible
		{
			get { return colorChooser.IsColorPickerVisible; }
		}

		/// <summary>
		/// Handles the Click event of the OK Button control.
		/// </summary>
		/// <param name="sender">The source of the event.</param>
		/// <param name="e">The <see cref="System.Windows.RoutedEventArgs"/> 
		/// instance containing the event data.</param>
		private void btnOK_Click(object sender, RoutedEventArgs e)
		{
			DialogResult = true;
		}
	}
}
